<?php
/**
 * 变量操作
 * 
 * Created		: 2011-06-14
 * Modified		: 2011-07-06 
 * @link		: http://www.qixbo.com
 * @copyright	: [Qixbo.Com] (c) 2011
 * @version		: 0.2.0
 * @author		: Joseph Chen (jsph.chen@gmail.com)
 */
class Variable
{
	/**
	 * 判断变量是否纯数字(整型或字符串
	 * @param int | string $s
	 * @return Boolean
	 */
	public static function is_digit($s) {
		return (is_int($s) || ctype_digit($s));
	}
	
	/**
	 * 递归将对象转换成数组
	 * @param object $obj
	 */
	public static function obj2arr($obj)
	{
		$obj = (array)$obj; 
		foreach ($obj as $k => $v) {  
			if (is_object($v)||is_array($v)) {   
				$obj[$k] = self::obj2arr($v);  
			} else {
				$obj[$k] = $v;
			}
		}
		return $obj;
	}
}
